<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\CouponType;

class Goods extends Model
{
    use HasFactory;
    protected $table = 'goods';

    public function getGoodsCoveAttribute($value)
    {
        return getDomain().'/uploads/'.$value;
    }

    /**
     *
     * @author Bryant
     * @date 2021-04-15 13:59
     *
     * 关联分类
     */
    public function type()
    {
        return $this->hasOne(CouponType::class,'id','type_id');
    }

    public function isOpen()
    {
        return [
            1 => '上架',
            2 => '下架'
        ];
    }


}
